<template>
  <div>
    <div class="selected_container">
      <div class="selected_wrapper">
        <div
          v-for="(item, index) in selectedData"
          :key="index"
          class="selected_item_box"
          @click="onClick(item.id)"
        >
          <div class="selected_img">
            <img :src="item.pic" />
          </div>
          <div class="item_title">
            <p class="selected_title">{{ item.title }}</p>
            <p class="selected_title selected_title_active">
              {{ item.descript }}
            </p>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    selectedData: {
      type: Array,
      requiresd: true,
    },
  },
  methods: {
    onClick(id) {
      //点击跳转详情页
      console.log(id);
      this.$router.pushRouteByQuery(
        "/selectedDetails",
         id 
      );
    },
  },
};
</script>

<style lang="scss" scoped>
.selected_container {
  width: 100%;
  height: 12rem;
  //   background: red;
  overflow: scroll;
  .selected_wrapper {
    width: 450%;
    height: 100%;
    display: inline-flex;
    justify-content: space-between;
    align-items: center;

    .selected_item_box {
      width: 20%;
      height: 100%;
      margin-left: 0.8%;
      .selected_img {
        width: 100%;
        height: 80%;
        img {
          width: 100%;
          height: 100%;
          border-radius: 0.2rem;
        }
      }
      .item_title {
        width: 100%;
        display: inline-flex;
        flex-wrap: wrap;
        justify-content: flex-start;
        align-items: center;
        .selected_title {
          font-size: 0.7rem;
          width: 100%;
          white-space: nowrap; //强制不换行
          overflow: hidden; //超出部分隐藏
          text-overflow: ellipsis; //显示‘...’
        }
        .selected_title_active {
          color: lightgray;
        }
      }
    }
  }
}
</style>